import axios from 'axios'
axios.defaults.withCredentials = true

export function fetch (url, params) {
  return new Promise((resolve, reject) => {
    axios.post(url, params)
      .then(response => {
        resolve(response.data)
      })
      .catch((error) => {
        reject(error)
      })
  })
}

export default {

  getDetail (url) {
    return fetch('/api/posts/1')
  },
  commonApi (url, params) {
    return fetch(url, params)
  }
}
